package com.zxm.edu.controller;

import com.alipay.api.AlipayApiException;
import com.zxm.edu.entity.AlipayBean;
import com.zxm.edu.entity.IPayModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName AliPayController
 * @Description TODO
 * @Author silence.Z
 * @Date 2023/1/4 9:26
 * @Version 1.0
 */
@RestController
public class AliPayController {
    @Autowired
    private IPayModel model;

    @PostMapping(value = "/order/alipay")
    public String alipay(String outTradeNo, String subject, String totalAmount, String body) throws AlipayApiException {
        AlipayBean alipayBean = new AlipayBean();
        alipayBean.setOut_trade_no(outTradeNo);
        alipayBean.setSubject(subject);
        alipayBean.setTotal_amount(totalAmount);
        alipayBean.setBody(body);
        return model.aliPay(alipayBean);
    }
}